package com.zeropoint.demo.pojo;


import lombok.ToString;

/**
 * 物质资源指标标准化
 */
@ToString
public class MaterialResourceStandardized {

     //数据汇总
     //总人口
     public int totalPopulation;
     //家庭村外购房
     public int villageHousing;
     //住房来源形式
     public int sourceForm;
     //额外购房金额
     public double homePurchase;
     //住房面积
     public int housingArea;

     //数据整理
     //人均住房面积
     public double housingAreaPre;
     //耐用消费品金额
     public double durableGoods;

     //计算结果
     //人均住房面积赋值
     public double housingAreaPerAssignment;
     //耐用消费品赋值
     public double durableGoodsAssignment;
     //住房来源状况赋值
     public double housingSourceAssignment;
     //家庭村外购房赋值
     public double villageHousingAssignment;

     public MaterialResourceStandardized(FormTwo formTwo){
            this.totalPopulation = HumanResourceStandardized.totalPopulation;

            if("没有".equals(formTwo.other_housing)){
                villageHousing = 0;
            }else {
                villageHousing = 1;
            }

            if("自建".equals(formTwo.housing_source)){
                sourceForm = 1;
                housingSourceAssignment = 1;
            }else if("购买".equals(formTwo.housing_source)){
                sourceForm = 2;
                housingSourceAssignment = 1;
            }else if("安置".equals(formTwo.housing_source)){
                sourceForm = 3;
            }else if("租房".equals(formTwo.housing_source) || "租赁".equals(formTwo.housing_source)){
                sourceForm = 4;
                housingSourceAssignment = 0.5;
            }else{
                sourceForm = 5;
            }

            homePurchase = formTwo.other_house_money;

            if(formTwo.housing_area == 1){
                housingArea = 1;
                housingAreaPre = (double) 60/totalPopulation;
            }else if(formTwo.housing_area == 2){
                housingArea = 2;
                housingAreaPre = (double) 100/totalPopulation;
            }else if(formTwo.housing_area == 3){
                housingArea = 3;
                housingAreaPre = (double) 140/totalPopulation;
            }else{
                housingArea = 4;
                housingAreaPre = 0;
            }


         durableGoods = formTwo.car_number*80000+formTwo.transport_number*120000
                    +formTwo.airconditioner_number*2000+formTwo.refrigerator_number*2000
                    +formTwo.washing_number*800+formTwo.tv_number*1500+formTwo.motorcycle_number*2000
                    +formTwo.electric_number*1500+formTwo.computer_number*2000+formTwo.phone_number*1500;

         if(housingAreaPre >= 40){
             housingAreaPerAssignment = 1;
         }else {
             housingAreaPerAssignment = housingAreaPre/40;
         }

         if(durableGoods >= 15000){
             durableGoodsAssignment = 1;
         }else {
             durableGoodsAssignment = durableGoods/15000;
         }


         if(homePurchase >= 30){
             villageHousingAssignment = 1;
         }else {
             villageHousingAssignment = homePurchase/30;
         }
     }

    public static void main(String[] args) {
//         HumanResourceStandardized.totalPopulation = 4;
//        FormTwo formTwo = new FormTwo();
//        formTwo.housing_source = "租房";
//        formTwo.housing_money = 0;
//        formTwo.housing_area = 70;
//        formTwo.other_housing = "没有";
//        formTwo.other_house_money = 0;
//        formTwo.other_house_area = "无";
//        formTwo.airconditioner_number = 1;
//        formTwo.refrigerator_number = 1;
//        formTwo.washing_number = 1;
//        formTwo.tv_number = 1;
//        formTwo.electric_number = 1;
//        formTwo.phone_number = 2;
//        System.out.println(new MaterialResourceStandardized(formTwo));
        HumanResourceStandardized.totalPopulation = 12;
        FormTwo formTwo = new FormTwo();
        formTwo.housing_source = "购买";
        formTwo.housing_money = 4;
        formTwo.housing_area = 120;
        formTwo.other_housing = "没有";
        formTwo.other_house_money = 0;
        formTwo.other_house_area = "无";
        formTwo.airconditioner_number = 1;
        formTwo.refrigerator_number = 1;
        formTwo.washing_number = 1;
        formTwo.tv_number = 1;
        formTwo.phone_number = 6;
        System.out.println(new MaterialResourceStandardized(formTwo));
    }
}
